<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>循环</title>
    <script>
      // for
      console.log("=============== for =================");
      for (var i = 0; i < 10; i++) {
        console.log(i);
      }

      // for break
      console.log("================ for break ================");
      let users = ["dong", "xixi", "nan", "beibei"];
      for (var i = 0; i < users.length; i++) {
        if (users[i].length < 4) {
          break;
        }
        console.log(users[i]);
      }

      // for continue
      console.log("================ for continue ================");
      for (var i = 0; i < users.length; i++) {
        if (users[i].length < 4) {
          continue;
        }
        console.log(users[i]);
      }

      // while true (as while do)
      console.log("================ while true ================");
      let num = 0;
      while (num < users.length) {
        console.log(users[num]);
        num++;
      }

      // do while
      console.log("================ do while ================");
      num = 0;
      do {
        console.log(users[num]);
        num++;
      } while (num < users.length);
    </script>
  </head>
  <body></body>
</html>
